package main

import (
	gpt "gpt/chatmodel"
	"gpt/pojo"

	"github.com/gin-gonic/gin"
)

func main() {
	r := gin.Default()
	r.POST("/", func(c *gin.Context) {
		var query pojo.Question
		if err := c.ShouldBindJSON(&query); err != nil {
			c.JSON(500, gin.H{"message": err.Error(), "success": false})
			return
		}
		var str = gpt.ChatModel(query.Message).Output.Text
		c.JSON(200, gin.H{
			"message": str,
			"success": true,
		})
	})
	r.Run(":8081") // 监听并在 0.0.0.0:8080 上启动服务
}
